import axios from 'axios';
import React,{useEffect, useState} from 'react';
function Test2() {
    const [list,setlist] =useState([])
    useEffect(()=>{
        axios.get("./test.json").then(res=>{
            console.log(res.data)
            setlist(res.data)
        })
    },[])//参数1是函数，参数2是数组
    return (
        <div>
            {
            list.map(item=>
                <li key={item.id}>{item.name}</li>    
            )
            }
            
        </div>
    );
}

export default Test2;